import request from '@/utils/request.ts'
import {
  reqDictOptionselect,
  reqDictDataPageList,
} from '@/api/system/dict/type.ts'
import { queryParams } from '@/api/system/common'

enum API {
  DICT_DATA_LIST_URL = '/system/dict/data/list' /*获取全部菜单信息*/,
  DICT_OPTION_SELECT_URL = '/system/dict/type/optionselect' /*dict类型选择框中要展示的数据*/,
  DICT_DATA_TYPE = '/system/dict/data/type',
  DICT_DATA_ADD_URL = '/system/dict/data/add' /*添加字典数据*/,
  DICT_DATA_EDIT_URL = '/system/dict/data/edit' /*修改字典数据*/,
  DICT_DATA_DELETE_URL = '/system/dict/data/delete',
}

//分页查询
export const reqDictDataPageListUrl = (queryParams: any) => {
  return request({
    url: API.DICT_DATA_LIST_URL,
    method: 'get',
    params: queryParams,
  })
}

/*dict类型选择框中要展示的数据*/
export const reqDictOptionselect = () => {
  return request.get<any, reqDictOptionselect>(API.DICT_OPTION_SELECT_URL)
}

/*根据类型查找数据*/
export const reqDictsDataByType = (dictType: string) => {
  return request.get<any, any>(API.DICT_DATA_TYPE + '/' + dictType)
}

/*添加字典数据*/
export const reqDictDataAddUrl = (form: any) => {
  return request({
    url: API.DICT_DATA_ADD_URL,
    method: 'post',
    data: form,
  })
}

/*修改字典数据*/
export const reqDictDataEditUrl = (form: any) => {
  return request({
    url: API.DICT_DATA_EDIT_URL,
    method: 'put',
    data: form,
  })
}

export const reqDictDataDeleteUrl = (dictCodes: any) => {
  return request({
    url: API.DICT_DATA_DELETE_URL + '/' + dictCodes,
    method: 'delete',
  })
}
